package com.zhentao.controller;


import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.pojo.management.TbMenu;
import com.zhentao.service.ITbMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mp
 * @since 2025-01-03
 */
@RestController
@RequestMapping("/menu")
public class TbMenuController {
    @Autowired
    private ITbMenuService tbMenuService;

    @GetMapping("/list")
    public ResponseResult menuList() {
        return tbMenuService.menuList();
    }

    @GetMapping("/Alllist")
    /**
     * @description:查询所有权限集合
     * @author: muhaoyang
     * @date: 2025/1/8 11:39
     * @param: []
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult menuAllList() {
        return tbMenuService.menuAllList();
    }

    @GetMapping("/selectList")
    /**
     * @description:查询权限集合
     * @author: muhaoyang
     * @date: 2025/1/6 13:31
     * @param: [menuName]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult selectList(@RequestParam(value = "menuName",required = false) String menuName) {
        return tbMenuService.selectList(menuName);
    }

    @PostMapping("/add")
    /**
     * @description:添加权限
     * @author: muhaoyang
     * @date: 2025/1/6 13:32
     * @param: [tbMenu]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult addMenu(@RequestBody TbMenu tbMenu) {
        return tbMenuService.addMenu(tbMenu);
    }

    @PutMapping("/update")
    /**
     * @description:修改权限
     * @author: muhaoyang
     * @date: 2025/1/6 13:33
     * @param: [tbMenu]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult updateMenu(@RequestBody TbMenu tbMenu) {
        return tbMenuService.updateMenu(tbMenu);
    }

    @DeleteMapping("/delete")
    /**
     * @description:删除权限
     * @author: muhaoyang
     * @date: 2025/1/6 13:34
     * @param: [id]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult deleteMenu(@RequestParam("id") Integer id) {
        return tbMenuService.deleteMenu(id);
    }

    @GetMapping("/getParent")
    /**
     * @description:查询父级菜单
     * @author: muhaoyang
     * @date: 2025/1/6 13:33
     * @param: []
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult getParent() {
        return tbMenuService.getParent();
    }

}

